package com.doit.demo03;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
/*
    idea 默认使用的是utf-8 所以在解码的时候.要选择对
    InputStreamReader 转为解码而生 指定编码的时候,不区分大小写
 */
public class demo01_inputstreamreader {
    public static void main(String[] args) throws IOException {
        InputStreamReader in1 = new InputStreamReader(new FileInputStream("D:\\work\\编码\\编码.txt"), "utf-8");
        InputStreamReader in2 = new InputStreamReader(new FileInputStream("D:\\work\\编码\\编码GBK.txt"), "GBK");

        char[] char1 = new char[1024];
        int read1 = in1.read(char1);
        System.out.println(new String(char1,0,read1));

        char[] chars = new char[1024];
        int read = in2.read(chars);
        System.out.println(new String(chars,0,read));
    }
}
